/*
 * HanoiGame.h
 *
 *  Created on: Oct 17, 2010
 *      Author: Jacob
 */

#pragma once
#include "stdafx.h"
#include "Tower.h"
#include "Stack.h"
#include <string.h>
#include <sstream>
#include <iostream>
using std::string;
using std::ostringstream;
using std::stringstream;
using std::cout;
using std::cin;

class HanoiGame
{
public:
	static HanoiGame* newGameWithNumPegsAndTowers(int numberOfPegs);
	void play();
	string toString();
	virtual ~HanoiGame();
private:
	int turnsTaken;
	ostringstream takeTurnMessage;
	int numberOfPegs;
	static const int numberOfTowers = 3;
	Tower* towers[numberOfTowers];
	Tower* generateStartingTower();
	void takeTurn();
	void solveProblem(int pegCount, int startingTower, int destinationTower, int extraTower);
	void validateNumberOfPegs(int &numberOfPegs);
	void generateTowers();
	HanoiGame(int numberOfPegs);
};
